package com.byb.server.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 优缺点
 */
@ApiModel(description = "优缺点")
@Entity
@Table(name = "achievement")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "achievement")
public class Achievement implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 优点
     */
    @ApiModelProperty(value = "优点")
    @Lob
    @Column(name = "advantage")
    private String advantage;

    /**
     * 缺点
     */
    @ApiModelProperty(value = "缺点")
    @Lob
    @Column(name = "drawback")
    private String drawback;

    @ManyToOne
    private Product product;

    // jhipster-needle-entity-add-field - Jhipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAdvantage() {
        return advantage;
    }

    public Achievement advantage(String advantage) {
        this.advantage = advantage;
        return this;
    }

    public void setAdvantage(String advantage) {
        this.advantage = advantage;
    }

    public String getDrawback() {
        return drawback;
    }

    public Achievement drawback(String drawback) {
        this.drawback = drawback;
        return this;
    }

    public void setDrawback(String drawback) {
        this.drawback = drawback;
    }

    public Product getProduct() {
        return product;
    }

    public Achievement product(Product product) {
        this.product = product;
        return this;
    }

    public void setProduct(Product product) {
        this.product = product;
    }
    // jhipster-needle-entity-add-getters-setters - Jhipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Achievement achievement = (Achievement) o;
        if (achievement.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), achievement.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Achievement{" +
            "id=" + getId() +
            ", advantage='" + getAdvantage() + "'" +
            ", drawback='" + getDrawback() + "'" +
            "}";
    }
}
